|
|
|
|
|
|
|
' Allocate connection handle:
intResult = SQLAllocConnect(hEnv, hDbc)
If intResult <> sqlSuccess Then
Err.Raise vbObjectError + 3, App.EXEName, "Unable to allocate connection handle"
Connect = intResult
Exit Function
End If
'
' Set cursor driver
intResult = SQLSetConnectOption(hDbc, sqlODBCCursors, intCursorDriver)
If intResult <> sqlSuccess Then
sqlErrorMsg "Error Setting CursorDriver"
Exit Function
End If
'
' Login to data source
intResult = SQLConnect(hDbc, strDataSource,
Len(strDataSource), strUserID, Len(strUserID), strPassword, Len(strPassword))
If intResult <> sqlSuccess And intResult <> sqlSuccessWithInfo Then
sqlErrorMsg "Unable to connect to DataSource [" & strDataSource & "]"
Connect = intResult
Exit Function
End If
'
' Allocate statement handle.
intResult = SQLAllocStmt(hDbc, hStmt)
If intResult <> sqlSuccess Then
sqlErrorMsg "Unable to allocate statement handle"
Connect = intResult
Exit Function
End If
'
' set cursor type (result set)
intResult = SQLSetStmtOption(hStmt, sqlCursorType, intResultSetType)
If intResult <> sqlSuccess Then
sqlErrorMsg "Error Setting ResultsetType"
Exit Function
End If
'
' set locktype
intResult = SQLSetStmtOption(hStmt, sqlConcurrency, intLockType)
If intResult <> sqlSuccess Then
sqlErrorMsg "Error Setting LockType"
Exit Function
End If
'
Connect = sqlSuccess
'
End Function |
|
|
|
|
|
|
|
|
The routine in Listing 19.7 performs several chores. The first operation establishes a data-source connection handle. Then, after setting the connection type by using the selected CursorDriver, the actual attempt to connect to the data source is performed. The DataSource, |
|
|
|
|
|